home *** CD-ROM | disk | FTP | other *** search
- ' ***************************************************************
- ' * CheckTS_Sessions.vbs *
- ' * By Vittorio Pavesi (www.vittorio.tk) *
- ' * *
- ' * Check number of active Terminal Server Sessions *
- ' * and return details (works only on 2003 or greater) *
- ' ***************************************************************
-
- CheckTS(2)
-
- Sub CheckTS(MaxNSession)
- Set Sess1 = GetObject("winmgmts:{impersonationLevel=impersonate}").InstancesOf("Win32_TSAccount")
- SessionN = 0
- for each Session in Sess1
- ' WScript.Echo session.sid
- SessionN =SessionN +1
- Next
- if SessionN <= MaxNSession then
- WScript.Echo "OK"
- else
- WScript.Echo "Error"
- end if
- WScript.Echo SessionN & " TS sessions"
- End sub